#@layout()

#define main()
<div class="jfa-header-box" id="jfa-header-box">
	<div class="jfa-crumbs" id="jfa-crumbs">
		工艺点基础信息
	</div>
	#include("/_view/common/_header_right.html")
</div>
<div class="jfa-content-box" id="jfa-content-box">
	<div class="jfa-content" id="jfa-content">
	    <div class="margin-top-30">
			<form class="form-horizontal actionPanel" action="#" method="get">
		        <div class="row">
		             <div class="form-group col-lg-4">
		                 <label class="col-sm-3 control-label">工艺点编号</label>
		                 <div class="col-sm-9">
		                     <input type="text" id="form-locationCode" class="form-control" value="">
		                 </div>
		             </div>
		             <div class="form-group col-lg-4">
		                 <label class="col-sm-3 control-label">名称</label>
		                 <div class="col-sm-9">
		                     <input type="text" id="form-remark" class="form-control" value="">
		                 </div>
		             </div>
		             <div class="form-group col-lg-4">
                         <div class="col-sm-12">
                             <button type="button" class="btn btn-primary" onclick="searchLocation()">查询</button>
                             <button type="reset" class="btn btn-default">重置</button>
                         </div>
                     </div>
		         </div>
		    </form>
		</div>
		

		<!--<div id="toolbar" class="btn-group">-->
	        <!--<a class="btn btn-primary btn-sm" href="#(ctx)/admin/location/add">-->
				<!--<i class="fa fa-plus"></i>-->
				<!--创建工艺点-->
			<!--</a>-->
			<!---->
	    <!--</div>-->
		<table id="location">
			
		</table>
	</div>
</div>
<script type="text/javascript">
 	var datagridHeight=$("#jfa-content").height()-80;
 	$('#location').bootstrapTable({
        url: '#(ctx)/admin/location/list',         
        method: 'get',
        toolbar: '#toolbar',
        striped: true,
        cache: false,
        pagination: true,
        sortable: false,                    
        sortOrder: "asc",  
        queryParams: function (params) {
	            var data = { 
	                    pageSize: params.limit,
	                    offset: params.offset,
	                    'locationCode': $("#form-locationCode").val(),
	                    'remark': $("#form-remark").val(),
	            };
	            return data;
        },
        sidePagination: "server",
        pageNumber:1,
        toolbarAlign:"right",
        pageSize:210,         
        pageList: [210, 420,100],
        search: false,
        strictSearch: true,
        showColumns: false,
        showRefresh: false,             
        minimumCountColumns: 2,
        clickToSelect: true,               
       	height: datagridHeight,
        uniqueId: "id",
        showToggle:false,
        cardView: false,
        detailView: false,
        columns: [
            {
                field: 'location_code',  title: '工艺点编号'
            }, {
                field: 'remark',  title: '名称'
            }, {
                field: 'min_stay_time',  title: '最小停留时间(秒)'
            },{
                field: 'max_stay_time',  title: '最大停留时间(秒)'
            }, {
                field: 'control_flag',  title: '是否启用',formatter:flagFormatter
            }, {
                title: '操作',formatter:operaterFormatter
            }
        ],
        onLoadSuccess:function(){
            initMagicInput(prepareAction);
        }
    });

// function operaterFormatter(value, row, index){
// 	return "<a href='#(ctx)/admin/location/edit?id="+row.id+"'>"+
// 	"<i class='fa fa-pencil' title='修改'></i>"+
// 	" </a> &nbsp"+
// 	"<a  href='#' onclick='deleteLocation(\""+row.id+"\")'>"+
// 	"	<i class='fa fa-trash' title='删除'></i>"+
// 	"</a>"
// }
    function operaterFormatter(value, row, index){
        return "<a href='#(ctx)/admin/location/edit?id="+row.id+"'>"+
            "<i class='fa fa-pencil' title='修改'></i></a>"
    }

function searchLocation(){
	$('#location').bootstrapTable("refresh",{silent: true});
    layer.msg('操作成功');
}

function deleteLocation(id){
	layer.confirm("确认删除该记录？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/location/delete",
			data:{"id":id},
			dataType:"json",
			success:function(ret){
				$('#location').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}

    function flagFormatter(value,row,index) {
        var result="<input data-id='"+row.id+"'";
        if (value==1){
            result+=" checked ";
        }
        result+="type='checkbox' class='mgc-switch mgc-tiny'>";
        return result;
    }
    function prepareAction($this, state) {
        return {
            url: state ? "#(ctx)/admin/location/doControl" : "#(ctx)/admin/location/notControl",
            data : {
                id: $this.attr("data-id")
            }
        }
    }

</script>
#end
